/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */

package org.jeecg.modules.third.jg.report.freight.information.service;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.third.jg.report.freight.information.constant.HuaibeiReportConstant;
import org.jeecg.modules.third.jg.report.freight.information.constant.enums.ReportDocTypeEnum;
import org.jeecg.modules.third.jg.report.freight.information.dto.AppInfoDTO;
import org.jeecg.modules.third.jg.report.freight.information.model.ExchangeModel;
import org.jeecg.modules.third.jg.report.freight.information.model.R;
import org.jeecg.modules.third.jg.report.freight.information.util.WebUtils;
import org.jeecg.modules.third.jg.report.freight.information.util.sm.SM2Util;
import org.jeecg.modules.third.jg.report.freight.information.util.sm.SM4Util;
import org.jeecg.modules.wlhy.utils.HyCfgUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * @Description: 淮北平台上报服务
 * @author: duanlikao
 * @date: 2022年10月09日 10:58
 */
@Service
@Slf4j
public class HuaiBeiReportPlatformService {

    @Resource
    private RedisUtil redisUtil;

    @Value(value="${huaibei-report-platform.domain:https://wlhy.ahyg.com.cn/province-exchange-test/}")
    private String reportPlatformDomain;

    @Value(value="${huaibei-report-platform.username:}")
    private String username;

    @Value(value="${huaibei-report-platform.password:}")
    private String password;

    @Value(value="${huaibei-report-platform.publicKey:}")
    private String publicKey;

    @Value(value="${huaibei-report-platform.appId:}")
    private String appId;

    @Value(value="${huaibei-report-platform.appSecurity:}")
    private String appSecurity;

    @Value(value="${huaibei-report-platform.appSenderCode:}")
    private String appSenderCode;

    @Value(value="${huaibei-report-platform.appDebugSystem:}")
    private String appDebugSystem;

    public AppInfoDTO getAppInfo() {
        return AppInfoDTO.builder()
                .appId(this.appId)
                .appSecurity(this.appSecurity)
                .enterpriseSenderCode(this.appSenderCode)
                .debugSystem(this.appDebugSystem)
                .build();
    }

    private String getLoginToken() throws Exception {
        return "";
    }

    /**
     * 组装交换报文
     * @param reportDocTypeEnum 上报单据类型
     * @param jsonString 报文内容
     * @return
     */
    private ExchangeModel messageAssembly(ReportDocTypeEnum reportDocTypeEnum , String jsonString) throws Exception {
        return null;
    }

    /**
     * 发送上报
     * @param reportDocTypeEnum
     * @param jsonString
     */
    public String  sendReport(ReportDocTypeEnum reportDocTypeEnum ,String jsonString, boolean isUploadFile) throws Exception {
        return null;
    }
}
